package com.hjq.mapper;

import com.hjq.anno.State;
import com.hjq.pojo.Article;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Service;

import java.util.List;

@Mapper
public interface ArticleMapper {
    @Insert("insert into big_event.article (title, content, cover_img, state, category_id, create_user, create_time, update_time) values " +
            "(#{title}, #{content}, #{coverImg}, #{state}, #{categoryId}, #{createUser}, #{createTime}, #{updateTime})")
    void add(Article article);


    List<Article> list(Integer categoryId, String state, Integer userId);

    @Update("update big_event.article set title=#{title}, content=#{content}, cover_img=#{coverImg}, state=#{state}, " +
            "category_id=#{categoryId}, create_user=#{createUser}, update_time=#{updateTime} where id=#{id}")
    void update(Article article);

    @Select("select * from big_event.article where id=#{id}")
    Article detail(Integer id);

    @Delete("delete from big_event.article where id=#{id}")
    void delete(Integer id);
}
